package com.springCrud.simpleCrud.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.catalina.connector.ClientAbortException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

public class ExceptionResolver extends SimpleMappingExceptionResolver {
	
	protected final Log logger = LogFactory.getLog(ExceptionResolver.class);
	
	@Override
	protected ModelAndView doResolveException(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex) {
		
		if (ex instanceof ClientAbortException) {
			return null;
		}
		if (ex instanceof MaxUploadSizeExceededException) {
			
		}
		
		logger.error("An exception has occured.", ex);
		
		request.getSession().setAttribute("exception", ex);
		
		return super.doResolveException(request, response, handler, ex);
	}

}
